function Karty() {
	return {
		createList: function(config) {
				App.doGetRequestJson({
					url: config.url,
			 		onSucces: function(response) {
						var html ='';
					    $.each(response, function(index, item) {
					    	html += '<li data-role="list-divider" >' + item.data + '</li>';
					    	html += '<li data-icon="pencil"><a href="#" id="editKartaPracyLink" name="' + item.id  + '" onClick="javascript: new Karty().openEditWindow(' + item.id + ')">';
					    	html += '<h1>Godziny jazdy : <span style="color: #660022">' + item.godzinyJazdy + '</span></h1>';
					    	html += '<h1>Godziny wykładów : <span style="color: #660022">' + item.godzinyWykladow + '</span></h1>';
					    	html += '<h1>Godziny pozostałe : <span style="color: #660022">' + item.godzinyPozostale + '</span></h1>';
					    	html += '<p class="ui-li-aside">Status: <span style="color: blue"><strong>' + item.statusKarty + '</strong></span></p>';
					    	html += '</a></li>';
					    });
					    
						$('#' + config.listId).empty();
						$('#' + config.listId).append($(html));
						$('#' + config.listId).trigger('create');
						$('#' + config.listId).listview('refresh');
					    
					}
				});
		},
		bindAddWindowToButton : function(buttonId) {
			$(document).delegate(buttonId, 'click', function() {
				App.doGetRequestText({
					url: 'kartyPracy!add.action',
					onSucces: function(response) {
						$('<div>').simpledialog2({
						    mode: 'blank',
						    headerText: 'Nowa karta',
						    headerClose: true,
						    blankContent : response.replace(/\\n/g, ''),
						    width: '300px',
						    fullScreen: true,
							fullScreenForce: true
			  			})
					}
				});		
			});
		},
		openEditWindow: function(kartaId) {
			App.doGetRequestText({
				url: 'kartyPracy!edit.action?kartaId=' + kartaId,
				onSucces: function(response) {
					$('<div>').simpledialog2({
						mode: 'blank',
						headerText: 'Edycja karty',
						headerClose: true,
						blankContent : response.replace(/\\n/g, ''),
						width: '300px',
					    fullScreen: true,
						fullScreenForce: true
			  		})
				}
			});		
		}
	}
};